package cn.itsource.util;

/**
 * 返回统一的结果集
 */
    public class AjaxResult {
        //接口状态（true：成功；false：失败）
        private Boolean success = true;
        //返回前端的提示信息（成功）
        private String message = "操作成功";
        //存储返回给前端的数据
        private Object resultObj;
        //编码
        private Integer code;

        //无参构造
        public AjaxResult(){}
        //有参构造
        public AjaxResult(Boolean success, String message) {
            this.success = success;
            this.message = message;
        }

    public AjaxResult(Boolean success, String message, Object resultObj) {
        this.success = success;
        this.message = message;
        this.resultObj = resultObj;
    }

    //链式语法改造
        public static AjaxResult me(){
            return new AjaxResult();
        }
        public AjaxResult setSuccess(Boolean success) {
            this.success = success;
            return this;
        }
        public AjaxResult setMessage(String message) {
            this.message = message;
            return this;
        }
        public AjaxResult setResultObj(Object resultObj) {
            this.resultObj = resultObj;
            return this;
        }


    /**
     * 获取
     * @return success
     */
    public Boolean getSuccess() {
        return success;
    }

    /**
     * 获取
     * @return message
     */
    public String getMessage() {
        return message;
    }

    /**
     * 获取
     * @return resultObj
     */
    public Object getResultObj() {
        return resultObj;
    }

    public String toString() {
        return "AjaxResult{success = " + success + ", message = " + message + ", resultObj = " + resultObj + "}";
    }
}

